Modulus

Assignment

%=

Divides the operand on the left side by the

operand on the right side and assigns the

remainder to the left operand

Table 2.5: Assignment Operators

The following is a sample program:

// SPDX-License-Identifier: Some Identifier

pragma solidity ^0.8.10;

contract AssignmentContract {

uint a = 100;

function addAssignment() public returns(uint) {

return a += 10;

}

function subtractAssignment() public returns(uint) {

return a -= 10;

}

function multiplyAssignment() public returns(uint) {

return a *= 10;

}

function divideAssignment() public returns(uint) {

return a /= 10;

}

function modulusAssignment() public returns(uint) {

return a %= 10;

}

}

2.5.11.6 Conditional (or ternary) Operators

It is a ternary operator where we first evaluate the condition on the

left, and depending upon true or false, either of the two values on the

right is chosen and returned.

Refer to the following example: